package compare.test;

import common.ComparableTestData;
import common.TestData;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author cyt
 * @create 2020-10-13 15:53
 */
public class DemoB {
    public static void main(String[] args) {
        ArrayList<TestData> list = new ArrayList<>();
        list.add(new TestData(1, "aa", Collections.emptyList()));
        list.add(new TestData(2, "bb", Collections.emptyList()));
        list.add(new TestData(4, "dd", Collections.emptyList()));
        list.add(new TestData(5, "ee", Collections.emptyList()));
        list.add(new TestData(3, "cc", Collections.emptyList()));

        System.out.println("---------> 排序前");
        list.forEach(System.out::println);
        // Collections.sort(list, TestData::compareTo);

        Collections.sort(list, new ComparableTestData());
        System.out.println("---------> 排序后");
        list.forEach(System.out::println);
    }
}
